#ifndef DATA_REFLOW_DATA_CATCHER_H
#define DATA_REFLOW_DATA_CATCHER_H

#include "rclcpp/rclcpp.hpp"
#include "data_reflow_interfaces/msg/sensor_data.hpp"
#include "data_reflow/config_manager.h"
#include "data_reflow/data_buffer.h"
#include "data_reflow/sensor_type.h"

namespace data_reflow
{
    using SensorData = data_reflow_interfaces::msg::SensorData;

    class SensorDataPub : public rclcpp::Node
    {
    public:
        SensorDataPub();
        bool isDataCollectedSuccessfully(SensorType sensor_type);

    private:
        void load_config();                  // 加载配置
        void publish_camera_data();          // 摄像头采集+存储
        void publish_lidar_data();           // 激光雷达采集（可选）

        // 发布者
        rclcpp::Publisher<SensorData>::SharedPtr pub_camera_;
        rclcpp::Publisher<SensorData>::SharedPtr pub_lidar_;

        // 配置参数
        int camera_frequency_ = 30;
        int lidar_frequency_ = 15;
        bool camera_record_ = true;
        bool lidar_record_ = true;

        // 计数器与定时器
        uint32_t camera_count_ = 0;
        uint32_t lidar_count_ = 0;
        rclcpp::TimerBase::SharedPtr camera_timer_;
        rclcpp::TimerBase::SharedPtr lidar_timer_;

        // 发布状态标记
        bool has_camera_published_ = false;
        bool has_lidar_published_ = false;
    };
}  // namespace data_reflow

#endif  // DATA_REFLOW_DATA_CATCHER_H